package tech.aistar.controller.collecte;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.Collecte;
import tech.aistar.entity.Collectes;
import tech.aistar.service.collecte.ICollecteService;
import tech.aistar.service.collecte.ICollectesViewService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Administrator on 2019/10/1 0001.
 */
@Controller
//@RequestMapping("/collectiondel")
public class collecteviewdelcontroller {
    @Autowired
    private ICollecteService collecteService;
    @Autowired
    private ICollectesViewService collectesViewService;
    @RequestMapping("/delone")       //进行单个删除
    public String coldel(Model model, HttpServletRequest request){

       //单个输出
       // 收藏
        String aid =  request.getParameter("id");
        List<Collecte> collecteList = collecteService.coldelById(Integer.valueOf(aid));
        model.addAttribute("collecteList",collecteList);

        //视图
        List<Collectes> collectesviewList = collectesViewService.colFindAll();
        model.addAttribute("collectesviewList",collectesviewList);
        return "redirect:collection/list";
    }

    @RequestMapping("/delany")      //进行多个删除
    public String coldelany(Model model,HttpServletRequest request) {
        String pathInfo2 = request.getPathInfo();
        String[] ids = request.getParameterValues("id");
        for(String s:ids){
                  List<Collecte> collecteList2 = collecteService.coldelById(Integer.valueOf(s));
                   model.addAttribute("collecteList2",collecteList2);
                    System.out.println("s:"+s);
                }

        return "redirect:collection/list";
    }
}
